/*
	Initialize knockout viewmodels: cateVM, overviewVM, homeVM
*/
var optionLoading = {
	lines: 11, // The number of lines to draw
	length: 0, // The length of each line
	width: 6, // The line thickness
	radius: 10, // The radius of the inner circle
	corners: 1, // Corner roundness (0..1)
	rotate: 15, // The rotation offset
	direction: 1, // 1: clockwise, -1: counterclockwise
	color: '#000', // #rgb or #rrggbb
	speed: 1, // Rounds per second
	trail: 60, // Afterglow percentage
	shadow: false, // Whether to render a shadow
	hwaccel: false, // Whether to use hardware acceleration
	className: 'spinner', // The CSS class to assign to the spinner
	zIndex: 2e9, // The z-index (defaults to 2000000000)
	top: 'auto', // Top position relative to parent in px
	left: 'auto' // Left position relative to parent in px
};

var VM = function () {

	var cateVM = new CateVM(function (item) {
		overviewVM.isDisplayOverView(true);
		overviewVM.getByCategory(item, 0);
	}),

		overviewVM = new OverviewVM(function () {
			childTmpl('bookTmpl');
		}),

		isDisplayFooter = ko.observable(true),
		isDisplayPopupAdd = ko.observable(false),
		isDisplayPopupMedia = ko.observable(false),
		isDisplayBtnsShare = ko.observable(false),
		isDisplayArrowDown = ko.observable(false),
		isDisplaySettingStartPage = ko.observable(false),
		isNeedBackButtonAnimation = ko.observable(true),
		slidePageTitle = ko.observable(""),
		strPopupDetail = ko.observable(""),
		currentTab = ko.observable(startTab),
		strHaveAnyProblem = getLocalizeText('haveAnyProblem'),
		strSelectFolder = getLocalizeText('selectFolder'),
		strShareWith = getLocalizeText('shareWith'),
		strShareFacebook = getLocalizeText('shareFacebook'),
		strShareTwitter = getLocalizeText('shareTwitter'),
		strShareEmail = getLocalizeText('shareEmail'),
        strOverviewTempl = isWP ? 'wp_overviewTmpl' : 'overviewTmpl',
        strFavoriteTempl = isWP ? 'wp_favoriteListTmpl' : 'favoriteListTmpl',
        childOverviewTmpl = ko.observable(strOverviewTempl),
        // because differect template, need to check before set value
		childStartTmpl = isWP ? ko.observable('wp_startTmpl') : ko.observable('startTmpl'),
		isShowingExprireMessage = false,
		isLoginDisplay = ko.observable(isLogin),
		isShowSearchResult = ko.observable(false),
		childTmpl = ko.observable('browseTmpl'),
		tmpl = ko.observable('homeTmpl'),
		isViewSearch = ko.observable(false),
		isViewFavorite = ko.observable(false),
		screenHeight = 0,		

		// [ENHANCE] Move to app/vm
		homeVM = {
			isLoginFormVisible: ko.observable(false),
			isRegisterFormVisible: ko.observable(false),
            isLoginSSO: ko.observable(false),
			textGo: getLocalizeText('Go'),
			textLogin: getLocalizeText('Log in'),
			strLogin: getLocalizeText('login'),
			strGoDescription: getLocalizeText('goDescription'),
			strGo: getLocalizeText('go'),
			strPassword: getLocalizeText('password'),
			strEMail: getLocalizeText('eMail'),
			strSubmit: getLocalizeText('submit'),
			strBrowse: getLocalizeText('browse'),
			strNew: getLocalizeText('new_key'),
			strStart: getLocalizeText('start'),
			strFavorites: getLocalizeText('favorites'),
			strSettings: getLocalizeText('settings'),
			strAbout: getLocalizeText('aboutTitle'),
			strLastName: getLocalizeText('lastName'),
			strFirstName: getLocalizeText('firstName'),
			strConfirmPassword: getLocalizeText('confirmPassword'),
			strChoosePassword: getLocalizeText('choosePassword'),
			strFreeRegister: getLocalizeText('freeRegister'),
			strAlreadyRegister: getLocalizeText('alreadyRegister'),
            strLoginStyle: ko.observable(getLocalizeText('ssoLoginStyleTitle')),

			go: function () {
				

                // [WP]
				if (isWP) {
				    tmpl('wp_headerTmpl');
				}
                else{
                    $('.pt-page').addClass('pt-page-absolute');
                    tmpl('headerTmpl');
                }
				
				isLoginDisplay(isLogin);
				overviewVM.isDisplayOverView(false);
				
				if (isiOS){
					setTimeout(function(){startpageVM.getStartPage();}, 300);
				}
				else{
					setTimeout(function(){startpageVM.getStartPage();}, 1000);
				}
				

				var currTapTime = new Date().getTime();
				var lastGetCategory = localStore.get("lastTimeForGetCategory") == null ? 0 : parseInt(localStore.get("lastTimeForGetCategory"));
				if (currTapTime - lastGetCategory > 86400000) {
					localStore.save("lastTimeForGetCategory", currTapTime);
					/* check internet before set null */
					if (navigator.connection.type != Connection.NONE) {
						localStore.save("category", null);
					}
				}
			},

			login: function () {
				if (!CanLoad())
					return;
                if (homeVM.isLoginSSO()){
                    /* login style is sso */
                    if (isLoginSSOValidate($('#user_name_id').val())){
                        share.loginWithSSO($('#user_name_id').val(),
                                           function(entityResult){
                                           homeVM.setUserInfoToLocal($('#user_name_id').val(), entityResult, true);
                                           },
                                           function(){
                                           
                                           });
                    }
                }
                else{
                    if (isLoginValidate($('#user_name_id').val(), $('#password_id').val())) {
                        var datacontext = new DataContext();
                        var list = new ko.observableArray([]);
                        showLoadingDialog();
                        datacontext.login.get({
                            results: list,
                            username: encodeURIComponent($('#user_name_id').val()),
                            password: encodeURIComponent($('#password_id').val())
                        }).done(function () {
                            CheckExpireSession(
                                list, 
                                true,
                                function() {
                                               /* nerver run this function */
                                },
                                function(entityResult) {
                                    homeVM.setUserInfoToLocal($('#user_name_id').val(), entityResult, true);
                                });
                        }).fail(function (e) {
                                if (e.responseText != undefined && e.responseText != ""){
                                    var responseTextTemp = $.parseJSON(e.responseText);
                                    if (responseTextTemp.error_description != undefined){
                                        if (responseTextTemp.error != undefined && responseTextTemp.error == 'invalid_grant'){
                                            /* show local message */
                                            ShowErrorMessage(getLocalizeText('loginNotValid'));
                                        }
                                        else{
                                            ShowErrorMessage(responseTextTemp.error_description);
                                        }
                                    }
                                
                                }
                                else{
                                    ShowErrorMessage();
                                }
                            
                        });
                    }
                }
			},
            logout: function () {
                var datacontext = new DataContext();
                var listResult = new ko.observableArray([]);
                showLoadingDialog();
                isLoading = true;
                datacontext.logout.logout({
                    results: listResult
                }).done(function () {
                        stopLoading();
                    }).fail(function () {
                        stopLoading();
                    });
            },


			register: function () {
				if (!CanLoad())
					return;
				
				var strFirstNameValue = $('#first_name_id').val();
				var strLastNameValue = $('#last_name_id').val();
				var strEmailValue = $('#email_id').val();
				var strPasswordValue = $('#choose_password_id').val();
				var strPasswordConfirmValue = $('#confirm_password_id').val();

				if (isRegisterValidate(strEmailValue, strPasswordValue, strPasswordConfirmValue, strFirstNameValue, strLastNameValue)) {
					var datacontext = new DataContext();
					var entity = new ko.observable();
					var list = new ko.observableArray([]);
					list([]);
					showLoadingDialog();
					datacontext.register.register({
						results: list,
						firstName: strFirstNameValue,
						lastName: strLastNameValue,
						email: encodeURIComponent(strEmailValue),
						password: encodeURIComponent(strPasswordValue),
						passwordCheck: encodeURIComponent(strPasswordConfirmValue)
					}).done(function () {
                        CheckExpireSession(
                        list,
                        true,
                        function() {
                            /* nerver run this function */
                        }, 
                        function() {
                            $('#user_name_id').val(strEmailValue);
                            $('#password_id').val(strPasswordValue);
                            isUserActionClick = false;
                            homeVM.login();
                        });
					}).fail(function () {
						ShowErrorMessage();
					});
				}
			},

			setUserInfoToLocal: function(username, entity, goHome) {
                
                /* keep user name and islogin flag */
                if (username){
                    localStore.save("user_name_id", username);
                }
				
				isLogin = true;
                localStore.save(strIsLoginKey, true);
                
                /* keep refresh token and access token */
                strRefreshToken = entity.refreshToken();
                strAccessToken  = entity.accessToken();
                localStore.save(strRefreshTokenKey, strRefreshToken);
                localStore.save(strAccessTokenKey, strAccessToken);
                
				if (goHome) {
					homeVM.go();
				}
                favoriteVM.getFolders();
			},

			showHideLoginForm: function () {
                if (!CanLoad())
                    return;
				homeVM.isRegisterFormVisible(false);
				homeVM.isLoginFormVisible(!homeVM.isLoginFormVisible());
                if (homeVM.isLoginFormVisible()){
                    homeVM.setLoginGUI();
                    
                }
			},

			showHideRegister: function () {
                if (!CanLoad())
                    return;
				homeVM.isLoginFormVisible(false);
				homeVM.isRegisterFormVisible(!homeVM.isRegisterFormVisible());
                if (homeVM.isRegisterFormVisible()){
                    homeVM.isLoginSSO(false);
                }
			},
            switchLogin: function(){
                if (!CanLoad())
                    return;
                    
                var widthSSO = 94;
                var widthNormal = 88;
                
                if (isiOS){
	                widthSSO = 94;
	                widthNormal = 88;
                }
                else{
                	widthSSO = 98.5;
	                widthNormal = 97;
                }
                homeVM.isLoginSSO(!homeVM.isLoginSSO());
                if (homeVM.isLoginSSO()){
                    /* login style is sso */
                    $('#group-boder-login').css('display', 'none');
                    $('#login-password-group').css('display', 'none');
                    $("#login-email-group").animate({
                                                    width: '100%'
                                                    }, 300, function () {
                                                    
                                                    $('.login-narrow').addClass('left-narrow');
                                                    $('.login-narrow').removeClass('right-narrow');
                                                    
                                                    homeVM.strLoginStyle(getLocalizeText('normalLoginStyleTitle'));
                                                    });
                    $("#user_name_id").animate({
                                               width: widthSSO+'%'
                                               }, 300, function () {
                                               });
                    
                    
                    
                    
                    
                    
                }
                else{
                    /* login style is normal */
                    $("#login-email-group").animate({
                                                    width: '50%'
                                                    }, 300, function () {
                                                    $('#login-password-group').css('display', 'block');
                                                    $('#group-boder-login').css('display', 'block');
                                                    
                                                    homeVM.strLoginStyle(getLocalizeText('ssoLoginStyleTitle'));
                                                    $('.login-narrow').removeClass('left-narrow');
                                                    $('.login-narrow').addClass('right-narrow');
                                                    });
                    $("#user_name_id").animate({
                                               width: widthNormal+'%'
                                               }, 300, function () {
                                               });
                    
                }
                
            },
            setLoginGUI: function(){
                /* is show login */
                var widthSSO = 94;
                var widthNormal = 88;
                
                if (isiOS){
	                widthSSO = 94;
	                widthNormal = 88;
                }
                else{
                	widthSSO = 98.5;
	                widthNormal = 97;
                }
                
                if (homeVM.isLoginSSO()){
                    /* is showing sso login */
                    $('#login-email-group').css('width', '100%');
                    $('#user_name_id').css('width', widthSSO+'%');
                    $('#login-password-group').css('display', 'none');
                    $('#group-boder-login').css('display', 'none');
                    
                    $('.login-narrow').addClass('left-narrow');
                    $('.login-narrow').removeClass('right-narrow');
                    
                    homeVM.strLoginStyle(getLocalizeText('normalLoginStyleTitle'));
                }
                else{
                    /* is showing normal login */
                    $('#login-email-group').css('width', '50%');
                    $('#user_name_id').css('width', widthNormal+'%');
                    $('#login-password-group').css('display', 'block');
                    $('#group-boder-login').css('display', 'block');
                    
                    $('.login-narrow').removeClass('left-narrow');
                    $('.login-narrow').addClass('right-narrow');
                    
                    homeVM.strLoginStyle(getLocalizeText('ssoLoginStyleTitle'));
                }
            }
		},

		init = function () {},

		getTmpl = function () {
			return tmpl();
		},

		getChildTmpl = function () {
			return childTmpl();
		},

		getChildOverviewTmpl = function () {
			return childOverviewTmpl();
		},

		getChildStartTmpl = function () {
			return childStartTmpl();
		},

		wait = function (e) {
			var spinner = new Spinner(optionLoading).spin();
			$(e).append(spinner.el);
			console.log(e);
		},

		showPopupDetail = function (detail) {
			strPopupDetail(detail.text);
			$("body").append("<div class='modalWindow'>&nbsp;</div>");
			$("#popupDetailAnnotation").css({
				top: '-300px'
			});
			$("#popupDetailAnnotation").animate({
				top: topLocation
			}, 500, function () {});
		},

		hidePopupDetail = function (detail) {
			$("#popupDetailAnnotation").animate({
				top: $(document).height()
			}, 500, function () {
				$(".modalWindow").remove();
			});
		},

		// When user click on "More" button in scroll view
		viewNewestStartPage = function (page, item) {
			if (!CanLoad())
				return;
            // [iOS]
            if (isiOS){
                setTimeout(function () {
                    /* add temp overview */
                    var strKey = item.id() + model.settingsVM.getLanguageString();
                    if (overviewListFromSubcategory[strKey] != undefined) {
                        var listTemp = ko.observableArray(overviewListFromSubcategory[strKey]);
                        var listAnimationTemp = ko.observableArray([]);
                        var j = 0;
                        _.each(listTemp(), function (i) {
                            j++;
                            if (j <= 8) {
                                listAnimationTemp.push(i);
                            }

                        });
                        model.overviewVM.listAnimation(listAnimationTemp());
                    }
                   else{
                           model.overviewVM.listAnimation([]);
                   
                   }
                }, 1);
            }
			startpageVM.isStartPageWorkflow(2);
			isNeedBackButtonAnimation(true);
			slidePageAnimation(item.title(), true, function () {
				model.cateVM.listnext([]);
				bookVM.hideBtnsShare();
                               bookVM.setShowHideFontEdit(false);
				bookVM.stopMedia();
				settingsVM.showSettingScreen(false);
				startpageVM.isDisplayStartPage(false);
				overviewVM.isDisplayOverView(true);
				childOverviewTmpl(strOverviewTempl);
				stackViews.push(strSubCategory);
				overviewVM.getNewestForStartPage(page, item);
				overviewVM.isEditing(false);
				isDisplayPopupAdd(false);
				isDisplayPopupMedia(false);
			}, false, false, true, false);
		},

		// Main menu: Start page 
		viewStart = function () {
			// [DONE] Move to function: prevent click, check loading, check internet connection
			if (!CanLoad())
				return;

			// [ENHANCE] Move to function: show/hide views/elements, initialize objects in current view
			isLoginDisplay(isLogin);
			currentTab(startTab);
			bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
			bookVM.stopMedia();
			settingsVM.showSettingScreen(false);
			startpageVM.isDisplayStartPage(true);
			overviewVM.isEditing(false);
			isDisplayPopupAdd(false);
			isDisplayPopupMedia(false);
			isShowSearchResult(false);
			startpageVM.getStartPage();
			stackViews = null;
			stackViews = new Array();
			
		},

		// Main menu: Favorite page
		// [ENHANCE]: check phone/table for timeDelay
		viewFavorite = function (timeDelay) {
			if (isJqmGhostClick()) {
				return;
			}
			startpageVM.isStartPageWorkflow(0);
			isLoginDisplay(isLogin);
            isShowSearchResult(false);
			overviewVM.isEditing(false);
			overviewVM.list([]);
			isDisplayPopupAdd(false);
			isDisplayPopupMedia(false);
			currentTab(favoriteTab);
			model.cateVM.listnext([]);
			bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
			bookVM.stopMedia();
			settingsVM.showSettingScreen(false);

			// [ENHANCE] Remove NO-LOGIN
			if (isLogin) {
				var currentFavoriteFolderID = localStore.get("current_favorite_folder_id");
				if (favoriteVM.folders().length > 0) {
					bookVM.FavoriteFolder("Folder_" + favoriteVM.folders()[0].folderID());
					overviewVM.folderID(favoriteVM.folders()[0].folderID() + "");
					bookVM.FavoriteFolderLabel(favoriteVM.folders()[0].folderName());
					if (currentFavoriteFolderID != null) {
						for (var i = 1; i < favoriteVM.folders().length; i++) {
							if (currentFavoriteFolderID == (favoriteVM.folders()[i].folderID() + "")) {
								bookVM.FavoriteFolder("Folder_" + favoriteVM.folders()[i].folderID());
								overviewVM.folderID(favoriteVM.folders()[i].folderID() + "");
								bookVM.FavoriteFolderLabel(favoriteVM.folders()[i].folderName());
								break;
							}
						}
					}
				}
				if (localStore.get("is_first_sync_favorite") == null) {
					isUserActionClick = false;
					overviewVM.syncFavorite();
				}
			} else {
				bookVM.FavoriteFolder("Default_folder");
				bookVM.FavoriteFolderLabel(getLocalizeText('defaultFolder'));
			}
			if (isLogin && localStore.get("is_first_sync_favorite") == null) {
				//Do nothing
			} else {
				overviewVM.getFavorite(timeDelay);
			}
			overviewVM.isDisplayOverView(true);
			childOverviewTmpl(strFavoriteTempl);
			stackViews = null;
			stackViews = new Array();
			startpageVM.isDisplayStartPage(false);
			overviewVM.applyScrollPager();
			setTimeout(function applyScroll() {
				myScroll.refresh();
			}, 200);
		},

		// Main menu: Category page (childTmpl > childOverviewTmpl)
		viewBrowse = function () {
			if (!CanLoad())
				return;

			overviewVM.isDisplayOverView(false);
			startpageVM.isDisplayStartPage(false);
			childOverviewTmpl(strOverviewTempl);
			overviewVM.isEditing(false);
			isDisplayPopupAdd(false);
			isDisplayPopupMedia(false);
			isShowSearchResult(false);
			bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
			currentTab(browseTab);
			bookVM.stopMedia();
			settingsVM.showSettingScreen(false);
			startpageVM.isStartPageWorkflow(0);
			childTmpl('browseTmpl');
            cateVM.getCategory();
			stackViews = null;
			stackViews = new Array();
			if (document.getElementById('browse_category') != null) {
				document.getElementById('browse_category').style.visibility = 'hidden';
			}
		},

		// [ENHANCE] Move actions in Book detail to vm.book.js
		// View for click on "Buy the book" in Book detail
		viewBuyTheBook = function () {
			overviewVM.isEditing(false);
			isDisplayPopupAdd(false);
			isDisplayPopupMedia(false);
			bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
			bookVM.stopMedia();
			settingsVM.showSettingScreen(false);
			childTmpl('buyTheBookTmpl');
			stackViews.push(strBookDetail);
			if (isViewSearch()) {
				isViewSearch(!isViewSearch());
			}
			setTimeout(function applyScroll() {
				myScroll.refresh();
			}, 200);

			// [Android] [WP] [BB]
			setTimeout(function () {
                       if (!isiOS) {
                       $("a").on('tap touch click', function (e) {
                                 if (isJqmGhostClick()) {
                                 return false;
                                 }
                                 e.stopPropagation();
                                 e.preventDefault();
                                 window.open($(this).attr('href'), "_system");
                                 return false;
                                 });
                       }
                       }, 200);
		},

		// View for click on "Comments" in Book detail
		viewComments = function () {
			overviewVM.isEditing(false);
			isDisplayPopupAdd(false);
			isDisplayPopupMedia(false);
			bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
			bookVM.stopMedia();
			settingsVM.showSettingScreen(false);
			childTmpl('commentsTmpl');
			stackViews.push(strBookDetail);
			if (document.getElementById('add-comment') != null) {
				document.getElementById('add-comment').style.display = 'none';
			}
			if (document.getElementById('comment-list') != null) {
				document.getElementById('comment-list').style.display = 'block';
			}
			if (isViewSearch()) {
				isViewSearch(!isViewSearch());
			}
		},

		// View for click on "Email" icon in Book detail
		viewShareEmail = function () {
			if (isJqmGhostClick()) {
				return;
			}
			overviewVM.isEditing(false);
			isDisplayPopupAdd(false);
			isDisplayPopupMedia(false);
			bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
			bookVM.stopMedia();
			settingsVM.showSettingScreen(false);
			childTmpl('shareEmailTmpl');
			stackViews.push(strBookDetail);
			if (myScroll != null) {
				myScroll.refresh();
			}
			setTimeout(function applyScroll() {
				myScroll.refresh();
			}, 200);
		},

		// View for click on "Annotations" in Book detail
		viewAnnotations = function () {
			overviewVM.isEditing(false);
			isDisplayPopupAdd(false);
			isDisplayPopupMedia(false);
			bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
			bookVM.stopMedia();
			settingsVM.showSettingScreen(false);
			childTmpl('annotationsTmpl');
			stackViews.push(strBookDetail);
			if (isViewSearch()) {
				isViewSearch(!isViewSearch());
			}
		},

		// View for click on "Quotes" in Book detail
		viewQuotes = function () {
			if (isJqmGhostClick()) {
				return;
			}
			if (bookVM.entity().overView.preview() == false) {
                if (bookVM.entity().quote.quotes().length != 0){
                    overviewVM.isEditing(false);
                    isDisplayPopupAdd(false);
                    isDisplayPopupMedia(false);
                    bookVM.hideBtnsShare();
                    bookVM.setShowHideFontEdit(false);
                    bookVM.stopMedia();
                    settingsVM.showSettingScreen(false);
                    childTmpl('quotesTmpl');
                    stackViews.push(strBookDetail);
                    if (isViewSearch()) {
                        isViewSearch(!isViewSearch());
                    }
                }
                else{
                    showPopup(getLocalizeText("noResultsFound"));
                }
				
			} else {
				showPopup(getLocalizeText("need_get_summary"));
			}
		},
        viewFontList = function () {
            overviewVM.isEditing(false);
            isDisplayPopupAdd(false);
            isDisplayPopupMedia(false);
            bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
            bookVM.stopMedia();
            settingsVM.showSettingScreen(false);
            childTmpl('fontTmpl');
            stackViews.push(strBookDetail);
            if (isViewSearch()) {
                isViewSearch(!isViewSearch());
            }
        },
		// When user click on "Back" icon in Book detail
		backToOverview = function () {
			if (!CanLoad())
				return;
            
			model.cateVM.listnext([]);
            bookVM.setShowHideFontEdit(false);
			var strTitle = model.overviewVM.title();
			if (currentTab() == startTab) {
				model.isNeedBackButtonAnimation(false);
				if (startpageVM.isStartPageWorkflow() == 1 && model.isShowSearchResult() != true) {
					strTitle = "backToStart";
                    
                    startpageVM.viewStartBookbyZoomOutAnimation(function(){
                                                               overviewVM.isEditing(false);
                                                               isDisplayPopupAdd(false);
                                                               isDisplayPopupMedia(false);
                                                               bookVM.hideBtnsShare();
                                                               bookVM.setShowHideFontEdit(false);
                                                               bookVM.stopMedia();
                                                               settingsVM.showSettingScreen(false);
                                                               
                                                               startpageVM.isDisplayStartPage(true);
                                                               
                                                               setTimeout(function applyScroll() {
                                                                          myScrollPager.refresh();
                                                                          }, 200);
                                                               });
                    
                    
                    return;
				}
			} else {
				model.isNeedBackButtonAnimation(true);
			}
            
            overviewVM.overviewBookbyZoomOutAnimation(function(){
                                                          overviewVM.isEditing(false);
                                                          isDisplayPopupAdd(false);
                                                          isDisplayPopupMedia(false);
                                                          bookVM.hideBtnsShare();
                                                          bookVM.setShowHideFontEdit(false);
                                                          bookVM.stopMedia();
                                                          settingsVM.showSettingScreen(false);
                                                          overviewVM.isDisplayOverView(true);
                                                          
                                                          if (currentTab() == favoriteTab  && model.isShowSearchResult() != true) {
                                                          childOverviewTmpl(strFavoriteTempl);
                                                          } else if (startpageVM.isStartPageWorkflow() == 1 && model.isShowSearchResult() != true) {
                                                          startpageVM.isDisplayStartPage(true);
                                                          } else {
                                                          childOverviewTmpl(strOverviewTempl);
                                                          }
                                                          
                                                          setTimeout(function applyScroll() {
                                                                     myScrollPager.refresh();
                                                                     }, 200);
                                                          });
            
            
            return;
			model.slidePageAnimation(strTitle, false, function () {
				overviewVM.isEditing(false);
				isDisplayPopupAdd(false);
				isDisplayPopupMedia(false);
				bookVM.hideBtnsShare();
                 bookVM.setShowHideFontEdit(false);
				bookVM.stopMedia();
				settingsVM.showSettingScreen(false);
				overviewVM.isDisplayOverView(true);

				if (currentTab() == favoriteTab  && model.isShowSearchResult() != true) {
				    childOverviewTmpl(strFavoriteTempl);
				} else if (startpageVM.isStartPageWorkflow() == 1 && model.isShowSearchResult() != true) {
					startpageVM.isDisplayStartPage(true);
				} else {
				    childOverviewTmpl(strOverviewTempl);
				}

				setTimeout(function applyScroll() {
					myScrollPager.refresh();
				}, 200);
			}, false, true);
		},

		// [ENHANCE] move vm.category.js		
		backToSubCate = function () {
			if (!CanLoad())
				return;

			// isStartPageWorkflow:
			//	+ 0: NONE
			//	+ 1: Back to subcategory in view Browse
			//	+ 2: Back to Start page
			if (startpageVM.isStartPageWorkflow() == 2) {
				/* is back to Start page view */
				isNeedBackButtonAnimation(false);
				var strTitle = "backToStart";
				model.slidePageAnimation(strTitle, false, function () {
					isDisplayPopupAdd(false);
					isDisplayPopupMedia(false);
					bookVM.hideBtnsShare();
                     bookVM.setShowHideFontEdit(false);
					bookVM.stopMedia();
					settingsVM.showSettingScreen(false);
					overviewVM.isDisplayOverView(true);
					startpageVM.isDisplayStartPage(true);
				});

				return;
			}

			/* back to sub category */
			model.cateVM.listnext([]);
			model.cateVM.listnext(model.cateVM.list());
			model.isNeedBackButtonAnimation(true);

			/* destroy iscroll */
			if (myScrollPager != null) {
				myScrollPager.destroy();
				myScrollPager = null;
			}
			model.slidePageAnimation(model.cateVM.title(), false, function () {
				overviewVM.isEditing(false);
				isDisplayPopupAdd(false);
				isDisplayPopupMedia(false);
				bookVM.hideBtnsShare();
                 bookVM.setShowHideFontEdit(false);
				bookVM.stopMedia();
				settingsVM.showSettingScreen(false);
				overviewVM.isDisplayOverView(false);
				childTmpl('browseTmpl');
				applyScrollF();
				setTimeout(function applyScroll() {
					myScroll.refresh();
				}, 200);
			});
		},

		// Show/Hide elements when click on "Add a comment" button
		addComment = function () {
			if (isJqmGhostClick()) {
				return;
			}
			if (isLogin) {
				if ($('#add-comment').length)
					$('#add-comment').show();

				if ($('#comment-text').length)
					$('#comment-text').val('');

				if ($('#comment-list').length)
					$('#comment-list').hide();

				if (myScroll != null) {
					myScroll.refresh();
				}
			} else {
				showPopup(getLocalizeText("need_login"));
			}
		},

		// Show/Hide elements when click on "Cancel" button in Add comment
		cancelComment = function () {
			if (isJqmGhostClick()) {
				return;
			}
			$('#comment-text').blur();

			if ($('#add-comment').length)
					$('#add-comment').hide();

			if ($('#comment-list').length)
					$('#comment-list').show();

			if (myScroll != null) {
				myScroll.refresh();
			}
		},

		// Main menu: About page
		viewAbout = function () {
			if (!CanLoad())
				return;

			aboutVM.reloadLanguage();
			overviewVM.isDisplayOverView(false);
			startpageVM.isDisplayStartPage(false);
			currentTab(aboutTab);
			overviewVM.isEditing(false);
			isDisplayPopupAdd(false);
			isDisplayPopupMedia(false);
			isShowSearchResult(false);
			bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
			bookVM.stopMedia();
			if (isViewSearch()) {
				isViewSearch(!isViewSearch());
			}
			startpageVM.isStartPageWorkflow(0);
			settingsVM.showSettingScreen(false);
			childTmpl('aboutTmpl');
            aboutVM.getAbout();
			stackViews = null;
			stackViews = new Array();
		},

		// Serect page in About view (click on top right)
		viewSecrectPage = function () {
			if (!CanLoad())
				return;

			if (isViewSearch()) {
				isViewSearch(!isViewSearch());
			}
			childTmpl('secrectTmpl');
            
			var strDomainName = localStore.get(strDomainKey);
            
            strDomainName = strDomainName.replace('http://', '');
            strDomainName = strDomainName.replace('/', '');
            
            setTimeout(function(){
                       $('#domain_name_id').val(strDomainName);
                       $('#password_secret_id').val('');
                       }, 100);
            
		},

		// When user click on "Change" in Setting page. Call reLogin		
		viewLoginInformation = function () {
			if (isJqmGhostClick()) {
				return;
			}
			overviewVM.isEditing(false);
			isDisplayPopupAdd(false);
			isDisplayPopupMedia(false);
			bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
			if (isViewSearch()) {
				isViewSearch(!isViewSearch());
			}
			settingsVM.showSettingScreen(false);
			childTmpl('loginTmpl');
			stackViews.push(strSettingBack);
		},

		// Main menu: Setting page
		viewSettings = function () {
			if (!CanLoad())
				return;

			startpageVM.isStartPageWorkflow(0);
			currentTab(settingTab);
			overviewVM.isEditing(false);
			isDisplayPopupAdd(false);
			isDisplayPopupMedia(false);
			isShowSearchResult(false);
			bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
			bookVM.stopMedia();
			if (isViewSearch()) {
				isViewSearch(!isViewSearch());
			}
			overviewVM.isDisplayOverView(false);
			startpageVM.isDisplayStartPage(false);
			
			settingsVM.showSettingScreen(true);			
			
			stackViews = null;
			stackViews = new Array();
            settingsVM.getSettings();
		},

		// Show viewLoginInformation
		viewLoginInfoWhenExpire = function () {
			/* auto login failed => go to login page */
			/* show message when exprire session */
			if (!isShowingExprireMessage) {
				isShowingExprireMessage = true;
				showPopupWithCallback(getLocalizeText('exprireSessionPleaseReLogin'), function () {
					isShowingExprireMessage = false;
				});
			}

			model.settingsVM.clearAllData();
		},

		// Show/Hide search bar in Start Page/Browse Page
		viewSearch = function () {
			if (isJqmGhostClick()) {
				return;
			}
			if (isLoading) {
				return;
			}
			isDisplayPopupAdd(false);
			isDisplayPopupMedia(false);
			bookVM.hideBtnsShare();
            bookVM.setShowHideFontEdit(false);
			isViewSearch(!isViewSearch());
			if (myScroll != null) {
				myScroll.refresh();
			}
		},

		// [ENHANCE] Move to vm.customer.js
		// When user click on "Plus" icon in bottom of Customer Page
		viewSettingStartPage = function () {
			if (isJqmGhostClick()) {
				return;
			}
			if (navigator.connection.type == Connection.NONE) {
				showPopup(getLocalizeText("internetConnectionRequired"));
				return;
			}

			startpageVM.getStartPageSetting();
		},

		// When user click on "Close" icon
		closeSettingStartPage = function () {
			if (isJqmGhostClick()) {
				return;
			}
			backAction(strSettingStart);
		},

		// When user click on "OK" icon
		saveSettingStartPage = function () {
			if (isJqmGhostClick()) {
				return;
			}
			startpageVM.postStartPageSetting();
		},

		// When user click on Book item in Start page/ Overview page
		displayBookDetail = function () {
			if (isJqmGhostClick()) {
				return;
			}
			/* get path again */
			localStore.choosePath(bookVM.entity().overView.thumbnailMediumDisplay, bookVM.entity().header.thumbnailMedium());
			model.cateVM.listnext([]);
			model.isNeedBackButtonAnimation(true);
			model.slidePageAnimation("", false, function () {
				childTmpl('bookTmpl');
                model.bookVM.setTextColorDefault();
			});
		},

		// Scroll apply for: Browse page, Book detail page (and child views), Setting page, About page
		applyScrollF = function () {
			if (myScroll != null) {
				myScroll.destroy();
				myScroll = null;
			}
			myScroll = new iScroll('wrapper_scrollview', {
				hScroll: false,
				hideScrollbar: true,
				onBeforeScrollStart: function (e) {
					var target = e.target;
					while (target.nodeType != 1) target = target.parentNode;
					if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') {
						e.preventDefault();
						e.stopPropagation();
					}
				}
			});
		},

		applyEffectScroll = function (element) {
			/* apply open external browser */
			// [Android] [WP] [BB]
			if (!isiOS) {
				$("a").on('tap touch click', function (e) {
					if (isJqmGhostClick()) {
						return false;
					}
					e.stopPropagation();
					e.preventDefault();
					window.open($(this).attr('href'), "_system");
					return false;
				});
			}
			applyEffect(element);
			applyScrollF();
		},

		// Handle tap events
		applyEffect = function (element) {
			// [DONE] Combine event for multi seletors
			/* fast button for detail */
			$("#fastButtonBack").tapstart(function () {
                bookVM.setShowHideFontEdit(false);
                                          bookVM.hideBtnsShare();
				backAction(strOverview);
			});
			/* fast button for search */
			$("#fastButtonViewSearch").tapstart(function () {
				viewSearch();
			});
			/* fast button for browse */
			$(".fastButtonBrowse").tapstart(function () {
				backAction(strCategory);
			});
			/* fast button for overview */
			$("#fastButtonOverview").tapstart(function () {
				backAction(strSubCategory);
			});
			/* fast button for email, comment, quotes, annotation, buy the book */
			$("#fastButtonEmail, #fastButtonComment, #fastButtonQuotes, #fastButtonAnnotation, #fastButtonBuyTheBook, #fastButtonFont").tapstart(function () {
				backAction(strBookDetail);
			});
			/* fast button for sync favorite */
			$("#fastButtonSyncFavorite").tapstart(function () {
				overviewVM.syncFavorite();
			});
			/* bottom bar for fast button */
			/* fast button for start active*/
			$("#fastButtonViewStartActive, #fastButtonViewStart").tapstart(function () {
				viewStart();
			});
			/* fast button for browse active*/
			$("#fastButtonViewBrowseActive, #fastButtonViewBrowse").tapstart(function () {
				viewBrowse();
			});
			/* fast button for favorite Active*/
			$("#fastButtonViewFavoriteActive, #fastButtonViewFavorite").tapstart(function () {
				viewFavorite(10);
			});
			/* fast button for setting Active*/
			$("#fastButtonChange, #fastButtonViewSettingActive, #fastButtonViewSetting").tapstart(function () {
				viewSettings();
			});
			/* fast button for sync Active */
			$("#fastButtonViewAboutActive, #fastButtonViewAbout, #fastButtonBackSecrect").tapstart(function () {
				viewAbout();
			});
			/*
			// [ENHANCE] Improve for feature: highlight when user click on div (button)
			for (i in element) {
				if (element[i] instanceof HTMLDivElement) {
					$(".clickableEffect", element[i]).each(function () {
						$(this).tapstart(function () {
							$(this).addClass("login-tap");
						});
						$(this).tapend(function () {
							$(this).removeClass("login-tap");
						});
					});
				}
			}*/
			if (localStore.get("user_name_id") != null) {
				$('#user_name_id').val(localStore.get("user_name_id"));
			}
		},

		// [ENHANCE] Improve for feature: highlight when user click on list item (li)
		applyEffectLI = function (element) {
			if (element instanceof HTMLLIElement) {
				$(element).tapstart(function () {
					$(element).addClass("login-tap");
				});
				$(element).tapend(function () {
					$(element).removeClass("login-tap");
				});
			}
		},

		// Effect for showing setting popup in Start page
		showSettingPopupPage = function () {
			$("#settingStartPageId").show();
			// [iOS]
			if (isiOS) {
                $("#settingStartPageContentIdAnimation").hide();
				$("#settingStartPageContentId").show();
				$("#settingStartPageContentId").css({ top: '100%' });
			}
			// [ANDROID] [WP] [BB]
			if (isAndroid || isWP || isBB) {
				
				$("#settingStartPageContentIdAnimation").show();
				$("#settingStartPageContentIdAnimation").css({ y: '120%' });
				$("#settingStartPageContentId").css({ y: '5%' });
				$("#settingStartPageContentId").hide();
			}
			setTimeout(function () {
				// [iOS]
				if (isiOS) {
					animationToTop('#settingStartPageContentId', 60, 30, function () {});
				}
				// [ANDROID] [WP] [BB]
				if (isAndroid || isWP || isBB) {
					$("#settingStartPageContentIdAnimation").transition({
						y: '5%'
					}, 300, function () {
						$("#settingStartPageContentId").show();
						setTimeout(function () {
							$("#settingStartPageContentIdAnimation").hide();
							
						}, 1);
					});
				}
			}, 100);
		},

		hideSettingPopupPage = function () {
			// [iOS]
			if (isiOS) {
				setTimeout(function () {
					$('#settingStartPageContentId').animate({
						top: '100%'
					}, 200, function () {
						isDisplaySettingStartPage(false);
					});
				}, 200);
			}
			// [ANDROID] [WP] [BB]
			if (isAndroid || isWP || isBB) {			
				setTimeout(function () {
					$("#settingStartPageContentId").transition({
						y: '120%'
					}, 300, function () {
						isDisplaySettingStartPage(false);
						$("#settingStartPageId").hide();
					});
				}, 1);
			}
		},

		// Effect for sliding: Overview <-> Detail, Category <-> Sub Category, Sub Category <-> Overview
		slidePageAnimation = function (title, isSlideIn, callBack, isSlow, isIScrollDestroy, isDisplayOverView, isFixingIOS7) {
			if (isViewSearch()) {
				isViewSearch(!isViewSearch());
			}
			if (title == "backToStart") {
				$('#pageAnimationTitleStart').show();
				$('#pageAnimationTitleCate, #pageAnimationTitleBook').hide();
			} else {
				if (title == "") {
					$('#pageAnimationTitleStart, #pageAnimationTitleCate').hide();
					$('#pageAnimationTitleBook').show();
				} else {
					slidePageTitle(title);
					$('#pageAnimationTitleStart, #pageAnimationTitleBook').hide();
					$('#pageAnimationTitleCate').show();
				}
			}

			// [iOS]
			if (isiOS) {
				var timeDelayForOverviewAnimation = 1;
				if (isDisplayOverView != undefined && isDisplayOverView == true) {
					timeDelayForOverviewAnimation = 600;
					$('#pageAnimationOverview').css({
						display: 'block'
					});
					$('#pageAnimationCategory').css({
						display: 'none'
					});
				} else {
					timeDelayForOverviewAnimation = 1;
					$('#pageAnimationOverview').css({
						display: 'none'
					});
					$('#pageAnimationCategory').css({
						display: 'block'
					});
				}
				if (isFixingIOS7 != undefined && isFixingIOS7 == true) {
					$("#pageAnimation").css({
						left: '0'
					});
				}
			}
            // [Android] [WP] [BB]
			if (isAndroid || isBB || isWP){
				var timeDelayForOverviewAnimation = 1;
				if (isDisplayOverView != undefined && isDisplayOverView == true) {
					timeDelayForOverviewAnimation = 600;
					
					$('#pageAnimationCategory').css({
                                                    display: 'none'
                                                    });
				} else {
					timeDelayForOverviewAnimation = 1;
					
					$('#pageAnimationCategory').css({
                                                    display: 'block'
                                                    });
				}
			}
            
			$("#pageAnimation").show();

			// [ANDROID] [WP] [BB]
			if (isAndroid || isWP || isBB) {
				if (isSlideIn) {
					$("#pageAnimation").css({
						x: screen.width + 'px'
					});
				} else {
					$("#pageAnimation").css({
						x: '-' + screen.width + 'px'
					});
				}

				setTimeout(function () {
					animationToLeftRight('#pageAnimation', 5, 450, isSlideIn, function () {
						setTimeout(function () {
							callBack();
							setTimeout(function () {
								$("#pageAnimation").hide();
							}, 200);
						}, 100);
					});
				}, 200);
			}
			// [iOS]
			if (isiOS) {
				if (isSlideIn) {
					$("#pageAnimation").css({
						left: '100%'
					});
				} else {
					$("#pageAnimation").css({
						left: '-100%'
					});
				}

				setTimeout(function () {
					animationToLeftRight('#pageAnimation', 5, 350, isSlideIn, function () {
						setTimeout(function () {
							callBack();
							setTimeout(function () {
								$("#pageAnimation").css({
									display: 'none'
								});
							}, timeDelayForOverviewAnimation); /* for iphone */
						}, 100); /* for iphone */
					});
				}, 100);
			}
		},

		animationToLeftRight = function (contentId, position, duration, isLeft, callBack) {
            // [iOS]
            if (isiOS){
                var positionTemp = position;
                if (!isLeft) {
                    /*is right */
                    positionTemp = -position;
                }
                $(contentId).animate({
                                     left: positionTemp + '%'
                                     }, duration, function () {
                                     if (position > 0) {
                                     animationToLeftRight(contentId, Math.round(position / 2 - 0.3), duration*0.5, isLeft, callBack);
                                     } else {
                                     callBack();
                                     }
                                     });
                
            }
            else{
                var positionTemp = position;
                if (!isLeft) {
                    positionTemp = -position;
                }
                $(contentId).transition({
                                        x: positionTemp + 'px'
                                        }, duration, function () {
                                        if (position > 0) {
                                        animationToLeftRight(contentId, Math.round(position / 2 - 0.3), duration*0.5, isLeft, callBack);
                                        } else {
                                        callBack();
                                        }
                                        });
            }
			
		},

		animationToTop = function (contentId, position, duration, callBack) {
			$(contentId).animate({
				top: position + '%'
			}, duration, function () {
				if (position > 5) {
					if (Math.round(position / 1.4 - 0.5)) {
						animationToTop(contentId, Math.round(position / 1.4 - 0.5), duration, callBack);
					} else {
						animationToTop(contentId, 5, duration, callBack);
					}
				} else {
					callBack();
				}
			});
		},

		// Handle search event when user click on "OK" button in Search bar
		search = function () {
			if (!CanLoad())
				return;

			if (overviewVM.keySearch() == undefined || overviewVM.keySearch() == '') {
				showPopup(getLocalizeText('youNeedEnterAKeyWord'));
				return;
			}
			$('#input-search-ID').blur();

			bookVM.stopMedia();
			if (isViewSearch()) {
				isViewSearch(!isViewSearch());
			}
			overviewVM.getByKey();
		},

		// Validate register form 
		// [ENHANCE] Move to ultility functions
		isRegisterValidate = function (strEmailTemp, strPasswordTemp, strPasswordConfirmTemp, strFirstNameTemp, strLastNameTemp) {
			if (strFirstNameTemp.length == 0) {
				showPopup(getLocalizeText('pleaseEnterYourFirstName'));
				return false;
			}
			if (strLastNameTemp.length == 0) {
				showPopup(getLocalizeText('pleaseEnterYourLastName'));
				return false;
			}
			if (strEmailTemp.length == 0) {
				showPopup(getLocalizeText('youNeedInputEmail'));
				return false;
			}
			if (!isEmail(strEmailTemp)) {
				showPopup(getLocalizeText('youNeedInputEmail'));
				return false;
			}
			if (strPasswordTemp.length == 0) {
				showPopup(getLocalizeText('youNeedInputPassword'));
				return false;
			}
			if (strPasswordConfirmTemp.length == 0) {
				showPopup(getLocalizeText('pleaseEnterConfirmPassword'));
				return false;
			}
			if (strPasswordConfirmTemp != strPasswordTemp) {
				showPopup(getLocalizeText('thesePasswordsDoNotMatch'));
				return false;
			}
			return true;
		},

		// Validate for login form
		isLoginValidate = function (strEmailTemp, strPasswordTemp) {
			if (strEmailTemp.length == 0) {
				showPopup(getLocalizeText('youNeedInputEmail'));
				return false;
			}
			if (!isEmail(strEmailTemp)) {
				showPopup(getLocalizeText('youNeedInputEmail'));
				return false;
			}
			if (strPasswordTemp.length == 0) {
				showPopup(getLocalizeText('youNeedInputPassword'));
				return false;
			}
			return true;
		},		
        isLoginSSOValidate = function (strEmailTemp) {
            if (strEmailTemp.length == 0) {
                //show popup
                showPopup(getLocalizeText('youNeedInputEmail'));
                return false;
            }
            if (!isEmail(strEmailTemp)) {
                //show popup
                showPopup(getLocalizeText('youNeedInputEmail'));
                return false;
            }
            return true;
        },
		// Validate: check email pattern
		isEmail = function checkEmail(strEmail) {
			var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (!filter.test(strEmail)) {
				return false;
			}
			return true;
		};

	return {
		init: init,
		getTmpl: getTmpl,
		tmpl: tmpl,
		getChildTmpl: getChildTmpl,
		getChildOverviewTmpl: getChildOverviewTmpl,
		childStartTmpl: childStartTmpl,
		getChildStartTmpl: getChildStartTmpl,
		wait: wait,
		sessionVM: sessionVM,
		isViewSearch: isViewSearch,
		isViewFavorite: isViewFavorite,
		strPopupDetail: strPopupDetail,
		slidePageTitle: slidePageTitle,
		showPopupDetail: showPopupDetail,
		hidePopupDetail: hidePopupDetail,
		homeVM: homeVM,
		cateVM: cateVM,
		bookVM: bookVM,
		startpageVM: startpageVM,
		favoriteVM: favoriteVM,
		overviewVM: overviewVM,
		settingsVM: settingsVM,
		isDisplayFooter: isDisplayFooter,
		isDisplayPopupAdd: isDisplayPopupAdd,
		isDisplayPopupMedia: isDisplayPopupMedia,
		isDisplayBtnsShare: isDisplayBtnsShare,
		isDisplayArrowDown: isDisplayArrowDown,
		isLoginDisplay: isLoginDisplay,
		isDisplaySettingStartPage: isDisplaySettingStartPage,
		isNeedBackButtonAnimation: isNeedBackButtonAnimation,
		currentTab: currentTab,
		aboutVM: aboutVM,
		viewStart: viewStart,
		viewNewestStartPage: viewNewestStartPage,
		viewBrowse: viewBrowse,
		viewAbout: viewAbout,
		viewSecrectPage: viewSecrectPage,
		viewSearch: viewSearch,
		viewSettingStartPage: viewSettingStartPage,
		closeSettingStartPage: closeSettingStartPage,
		saveSettingStartPage: saveSettingStartPage,
		viewSettings: viewSettings,
		viewLoginInformation: viewLoginInformation,
		viewLoginInfoWhenExpire: viewLoginInfoWhenExpire,
		displayBookDetail: displayBookDetail,
		viewBuyTheBook: viewBuyTheBook,
		viewComments: viewComments,
		viewShareEmail: viewShareEmail,
		viewAnnotations: viewAnnotations,
		viewQuotes: viewQuotes,
        viewFontList: viewFontList,
		viewFavorite: viewFavorite,
		search: search,
		backToOverview: backToOverview,
		backToSubCate: backToSubCate,
		addComment: addComment,
		applyEffect: applyEffect,
		applyEffectScroll: applyEffectScroll,
		applyEffectLI: applyEffectLI,
		applyScrollF: applyScrollF,
		slidePageAnimation: slidePageAnimation,
		cancelComment: cancelComment,
		isLoginValidate: isLoginValidate,
        isLoginSSOValidate: isLoginSSOValidate,
		isEmail: isEmail,
		strHaveAnyProblem: strHaveAnyProblem,
		strShareWith: strShareWith,
		strShareFacebook: strShareFacebook,
		strShareTwitter: strShareTwitter,
		strShareEmail: strShareEmail,
		strSelectFolder: strSelectFolder,
		childOverviewTmpl: childOverviewTmpl,
		isShowSearchResult: isShowSearchResult,
		showSettingPopupPage: showSettingPopupPage,
		hideSettingPopupPage: hideSettingPopupPage
	};
}
